package com.qk.management.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qk.entity.Course;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CourseMapper extends BaseMapper<Course> {
    List<Course> list(@Param("name") String name,
                      @Param("subject") Integer subject,
                      @Param("target") Integer target
    );

    @Delete("delete from course where id = #{id}")
    void deleteById(Integer id);

    @Insert("insert into course(subject,name,price,target,description,create_time,update_time) values (#{subject},#{name},#{price},#{target},#{description},now(),now())")
    int insert(Course course);

    @Select("select * from course where id = #{id}")
    Course getById(Integer courseId);

    void update(Course course);

    @Select("select * from course")
    List<Course> findAll();

    List<Course> findBySubject(Integer subject);
}
